package com.tulingxueyuan.order.controller;

import com.tulingxueyuan.order.feignService.StockFeignService;
import com.tulingxueyuan.order.service.orderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/***
 * @Author 徐庶   QQ:1092002729
 * @Slogan 致敬大师，致敬未来的你
 */
@RestController
@RequestMapping("/order")
@RefreshScope  // 动态刷新
public class OrderController {

    @Autowired
    RestTemplate restTemplate;
    @Autowired
    orderService orderService;
    @Autowired
    StockFeignService stockFeignService;

    @Value("${author}")
    String author;

    @RequestMapping("/add")
    public String add(){
        System.out.println("下单成功!");
//        String msg = restTemplate.getForObject("http://stock-server/stock/reduct", String.class);
        orderService.add();
//        String msg = stockFeignService.reduct();
        return "Hello World 作者："+author;
    }

    @RequestMapping("/test")
    public String test(){
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return "Hello World";
    }
}
